package com.poc.oauth.resources.web.controller;

import com.poc.oauth.resources.model.Account;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.Random;

@SuppressWarnings("UnusedDeclaration")
@Controller
@RequestMapping(value = "account")
public class AccountController {
    private Random random = new Random(new Date().getTime());

    /**
     * restful request for account information
     */
    @SuppressWarnings("JavaDoc")
    @RequestMapping(value = "/{accountType}/{accountNumber}", method = RequestMethod.GET)
    public @ResponseBody
    Account account(@PathVariable String accountType, @PathVariable String accountNumber) {

        Account account = new Account();
        account.setName(accountType + ":" + accountNumber);
        account.setType(accountType);
        account.setNumber(accountNumber);
        account.setBalance(random.nextInt(10000000));

        return account;
    }

}
